import QtQuick
import QtQuick3D
//生成网格状排列的对象

Node{
    id:root
    property Component source

    function getNode(x,y,z){
        var index = x * yNum * zNum + y * zNum + z
        return repeater.objectAt(repeater).item
    }

    property int xNum:3
    property int yNum:3
    property int zNum:3
    property real xSpacing:10//每个物体中心点的距离
    property real ySpacing:10
    property real zSpacing:10

    Repeater3D{
        id:repeater

        property vector3d center:Qt.vector3d((xNum - 1) * xSpacing / 2,(yNum - 1) * ySpacing / 2,(zNum - 1) * zSpacing / 2)

        model: {
            var ret = []
            for(var i = 0;i<xNum;i++)
            {
                for(var j = 0;j<yNum;j++)
                {
                    for(var k = 0;k<zNum;k++)
                    {
                        ret.push({xIndex:i,yIndex:j,zIndex:k})
                    }
                }
            }

            return ret
        }

        Loader3D{
            sourceComponent: root.source

            property var xIndex:modelData.xIndex
            property var yIndex:modelData.yIndex
            property var zIndex:modelData.zIndex

            x:xIndex * xSpacing - repeater.center.x
            y:yIndex * ySpacing - repeater.center.y
            z:zIndex * zSpacing - repeater.center.z
        }

    }




}
